import { _decorator, Component, Label, Node, ProgressBar } from 'cc';
import { Soldier, SoldierProIndex } from '../entity/Soldier';
const { ccclass, property } = _decorator;

@ccclass('PropertyItem')
export class PropertyItem extends Component {
    @property(Label)
    proName: Label
    @property(Label)
    proVal: Label
    @property(ProgressBar)
    progressBar: ProgressBar

    start() {

    }

    setData(soldier: Soldier, pro: SoldierProIndex) {
        let max = Soldier.createMaxSoldier()
        switch (pro) {
            case SoldierProIndex.StepAttack:
                this.proName.string = '攻击'
                this.proVal.string = (soldier.stepAttack + soldier.rideAttack) + ''
                this.progressBar.progress = (soldier.stepAttack + soldier.rideAttack) / (max.stepAttack + max.rideAttack)
                break
            case SoldierProIndex.RideAttack:
                this.proName.string = '攻击'
                this.proVal.string = (soldier.stepAttack + soldier.rideAttack) + ''
                this.progressBar.progress = (soldier.stepAttack + soldier.rideAttack) / (max.stepAttack + max.rideAttack)
                break
            case SoldierProIndex.Speed:
                this.proName.string = '速度'
                this.proVal.string = soldier.speed + '格/时'
                this.progressBar.progress = soldier.speed / max.speed
                break
            case SoldierProIndex.StepDefense:
                this.proName.string = '对步兵防御'
                this.proVal.string = soldier.stepDefense + ''
                this.progressBar.progress = soldier.stepDefense / max.stepDefense
                break
            case SoldierProIndex.RideDefense:
                this.proName.string = '对骑兵防御'
                this.proVal.string = soldier.rideDefense + ''
                this.progressBar.progress = soldier.rideDefense / max.rideDefense
                break
            case SoldierProIndex.Transport:
                this.proName.string = '运载量'
                this.proVal.string = soldier.transport + ''
                this.progressBar.progress = soldier.transport / max.transport
                break
            case SoldierProIndex.Consume:
                this.proName.string = '消耗'
                this.proVal.string = soldier.consume + ''
                this.progressBar.progress = soldier.consume / max.consume
                break
        }
    }


}


